package com.token.iot.bratterycharging.boss.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageInfo;
import com.outstanding.framework.base.TransactionLogger;
import com.outstanding.framework.container.springmvc.WebContext;
import com.outstanding.framework.core.PendingException;
import com.token.iot.bratterycharging.boss.web.ReqPageDto;
import com.token.iot.bratterycharging.boss.dao.OperDAO;
import com.token.iot.bratterycharging.boss.service.AgentsService;
import com.token.iot.bratterycharging.boss.service.DeviceService;
import com.token.iot.bratterycharging.boss.service.MerchantService;



@Controller
@RequestMapping("/")
public class BossController {

	/** AgentsService服务 */
	@Autowired
	private AgentsService agentsService;
	
	/** AgentsService服务 */
	@Autowired
	private MerchantService merchantService;

	

	@Autowired
	private OperDAO operDao;
	
	@Autowired
	private AgentsService agentService;

	@ResponseBody
	@RequestMapping(value = "/login.do")
	public OperDTO login(@RequestBody OperDTO dto) throws PendingException {
		TransactionLogger.debug("staring login " + String.valueOf(dto == null) + " ");
		// dto.setRole("管理员");
		OperDTO operid = operDao.selectByUserNamePassword(dto.getUserName(), dto.getPassword());
		if (operid == null) {
			throw new PendingException(ResCode.LoginError);
		}
		WebContext.getSession().setAttribute("_operid", operid.getId());
		WebContext.getSession().setAttribute("_oper", operid);
		return operid;
	}

	

	
	


	
	
	
	
	
	

	
}
